home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / InfoTipManager.java < prev    next >
Text File  |  1998-09-21  |  2KB  |  63 lines

  1. package symantec.itools.awt;
  2.  
  3.  
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.FontMetrics;
  7. import java.awt.Panel;
  8.  
  9. /**
  10.  * This helper class draws InfoTips
  11.  * <p>
  12.  * An InfoTip is very small window that pops up to display a helpful
  13.  * message regarding the component the mouse is over. It appears if
  14.  * the mouse is held over the component for a short while.
  15.  * <p>
  16.  * @version 1.0
  17.  * @author Symantec
  18.  */
  19. public class InfoTipManager
  20. {
  21.     private static Panel infoTipPanel;
  22.  
  23.     /**
  24.      * Do not use, this is an all-static class.
  25.      */
  26.     public InfoTipManager() {
  27.     }
  28.  
  29.     /**
  30.      * Creates a new panel for the InfoTip as needed, and then returns it.
  31.      * The InfoTip is drawn in this panel.
  32.      * @return a panel for the InfoTip
  33.      */
  34.     public static Panel getInfoTipPanel()
  35.     {
  36.         if(infoTipPanel == null)
  37.         {
  38.             infoTipPanel = new Panel();
  39.             infoTipPanel.hide();
  40.             infoTipPanel.setLayout(null);
  41.         }
  42.  
  43.         return infoTipPanel;
  44.     }
  45.  
  46.     /**
  47.      * Draws the InfoTip in the InfoTip panel.
  48.      * @param x location of the InfoTip, x coordinate
  49.      * @param y location of the InfoTip, y coordinate
  50.      * @param s text to display in the InfoTip
  51.      * @param fm font used for InfoTip text
  52.      * @param bc background color used for the InfoTip
  53.      * @param fc foreground color used for the InfoTip
  54.      * @see #getInfoTipPanel
  55.      */
  56.     public static void draw(int x, int y, String s, FontMetrics fm, Color bc, Color fc)
  57.     {
  58.         infoTipPanel.reshape(x, y, fm.stringWidth(s), fm.getHeight());
  59.         infoTipPanel.setBackground(bc);
  60.         infoTipPanel.setForeground(fc);
  61.         infoTipPanel.show();
  62.     }
  63. }